#include<bits/stdc++.h>

using namespace std;
//扫雷
int a[21][21];
int n, m, k;

int main() {
    freopen("L.in", "r", stdin);
    while (cin >> n >> m >> k) {
        memset(a, 0, sizeof(a));
        while (k--) {
            int x, y;
            cin >> x >> y;
            a[x][y] = 9;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (a[i][j] == 9)continue;
                int tot = 0;
                for (int di = -1; di <= 1; di++) {
                    for (int dj = -1; dj <= 1; dj++) {
                        int ni = i + di;
                        int nj = j + dj;
                        if (ni < 0 || ni >= n || nj < 0 || nj >= m)continue;
                        if (a[ni][nj] == 9)++tot;

                    }

                }
                a[i][j] = tot;
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (a[i][j] == 9)
                    cout << "*";
                else
                    cout << a[i][j];
            }
            cout << endl;
        }
        cout << endl;


    }

    return 0;
}
